﻿using UnityEngine;
using System.Collections;

public class Trigger : MonoBehaviour 
{
	public GameObject[] doors;
	public enum Type {BLACKCRISTAL, WHITECRISTAL};
	public Type type;

	// Use this for initialization
	void Start () 
	{

	}
	
	// Update is called once per frame
	void Update () 
	{
	
	}

	void OnCollisionStay2D(Collision2D other)
	{
		if (Input.GetButton("Interaction")) //Fire1 = q
		{
			switch(type)
			{
			case Type.BLACKCRISTAL: //is only affected by the black character
					if (other.transform.tag == "BlackPlayer") 
					{
						foreach(GameObject door in doors)
						{
							door.gameObject.SetActive(false);
						}
					}
				break;
			case Type.WHITECRISTAL: //is only affected by the white character
					if (other.transform.tag == "WhitePlayer") 
					{
						foreach(GameObject door in doors)
						{
							door.gameObject.SetActive(false);
						}
					}
				break;
			}
		}
	}
	
}
